import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class Text_Widget extends StatelessWidget {
  const Text_Widget({Key? key}) : super(key: key);
  void _getToast(){
    print("ddd");
  }
  @override
  Widget build(BuildContext context) {

    void clickStart(){
      _getToast();
    }
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          leading:IconButton(icon:Icon(Icons.arrow_back),onPressed: clickStart,),
          title: Text("Text练习",
              style: TextStyle(
                  color: Colors.yellow,
                  fontSize: 20,
                  fontWeight: FontWeight.bold)),
          backgroundColor: Colors.blue,
          foregroundColor: Colors.yellow,
        ),
        body: Body(),
        // body: Body2(visible: true,),
      ),
    );
  }
}

class Body extends StatefulWidget {
  @override
  _BodyState createState() => _BodyState();
}

class _BodyState extends State<Body> {
  static const _platform = const MethodChannel("com.example.flutter_demo/getApp");
  Future<void> _getActivityResult() async {
    String result;
      final String level = await _platform.invokeMethod('getData');
      result =level;
      print("result="+result);
    setState(() {
//    _result = result;
    });
  }
  void _getToast(){
    print("ddd");
    _getActivityResult();
    _platform.invokeMethod("Toast");
  }
  bool _flag=true;
  void _clickDemo(){
    _getToast();
   setState(() {
     // this._flag=!this._flag;
   });
  }
  @override
  Widget build(BuildContext context) {
    return Container(
        padding: EdgeInsets.only(top: 50),
        height: double.infinity,
        color: Colors.yellow,
        width:double.infinity,
        child: GestureDetector(
            onTap: _clickDemo,
            child: Text(_flag?"这里是内里是内里是内里是内里是内里是内里是内里是内里是内里是内里是内里是内里是内容":"",
              overflow: TextOverflow.ellipsis,
              style: TextStyle(
                  fontSize: 40,
                  decoration: TextDecoration.none,
                  // backgroundColor: Colors.red,
                  color: Colors.black,
                  fontWeight: FontWeight.bold),
              textAlign: TextAlign.center,)
        )
    );
  }
}
class Body2 extends StatelessWidget {

  final bool visible;
  const Body2({Key? key, required this.visible}) : super(key: key);
  void _getToast(){
    print("ddd");
  }
  @override
  Widget build(BuildContext context) {
    return AnimatedOpacity(
      opacity: visible?1.0:0.0,
        duration: Duration(milliseconds: 300),
        child: GestureDetector(
          onTap: _getToast,
            child: Text("这里是内里是内里是内里是内里是内里是内里是内里是内里是内里是内里是内里是内里是内容",
              overflow: TextOverflow.ellipsis,
              style: TextStyle(
                  fontSize: 40,
                  decoration: TextDecoration.lineThrough,
                  // backgroundColor: Colors.red,
                  color: Colors.black,
                  fontWeight: FontWeight.bold),
              textAlign: TextAlign.center,)
        )
    );
  }
}


